# -*- coding: utf-8 -*-
"""
created on 2017/12/8 9:47

@author: didichen
"""
# 开始url：http://www.pythonchallenge.com/pc/return/bull.html
# 结束url：http://www.pythonchallenge.com/pc/return/5808.html

# 1
# 11                      代表前面是1个1
# 21                     代表前面是2个1
# 1211                 代表前面是1个2,1个1
# 111221            代表前面是1个1,1个2,2个1
# a = ['1', '11', 21, 1211, 111221]

import re
def describe(s):
    lists = [str(len(m.group(0))) + m.group(1) for m in re.finditer(r"(\d)\1*", s)]
#     print lists
    return "".join(lists)
s = "1"
for dummy in range(30):
    s = describe(s)
    print(s)
print(len(s))